<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@include file="/WEB-INF/templates/common/taglib.jsp"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html> 
<head> 
<title> New Document </title> 
<meta name="Generator" content="EditPlus">  
<meta name="Author" content="">  
<meta name="Keywords" content="">  
<meta name="Description" content=""> 
</head><script language="javascript">	
</script>
<body>    
<OBJECT 
ID="ocx"  CLASSID="CLSID:49903B72-9F44-41E1-A79B-B85A8BCEB89A"> 
</OBJECT>
<script language="javascript">
   // Open();
    function Open()
    {  
	 //ocx.SetScan();

	// ocx.LoadLibraryEngine();
	
        ocx.DSMode(6);
        var pp= ocx.openScanner();
        if(1==pp)
        {
             alert("open scanner success");
	     
        }
				else
				{
						var Error = ocx.GetErrorCode();
						alert(Error);
				}
    }
	

    function  Scan()
    {
				//ocx.AutoDiscardBlankPages=-1;
				ocx.GetPageNum(0);
       			 ocx.ShowUI = 0;
				ocx.AutoScan = 0;
				//var Path= document.getElementById("FilePath").value;
				//var FPrefix= document.getElementById("FilePrefix").value;
				//var nStartIndex=0;
				//var nIndexLength=5;
				//ocx.GetImageName(Path,FPrefix,nStartIndex,nIndexLength);
				//ocx.SetImageName(Path,FPrefix,nStartIndex, 5);
				var Resol =  document.getElementById("Resolution").value;
				ocx.ScanResolution = Resol;
				var currSelectIndex = document.getElementById("PicType").selectedIndex;    
				ocx.ScanPixelType = 2;
				var picTypeEx = document.getElementById("PicTypeEx").selectedIndex;
				ocx.ImageFormat = picTypeEx;
				var scanTypeIdx = document.getElementById("ScannerType").selectedIndex;
				ocx.ScanSourceType = scanTypeIdx;
				var TiffIdx = document.getElementById("TiffCom").selectedIndex;
				ocx.TiffCompressType = TiffIdx;
				var comRate = document.getElementById("CompressRate").value;
				ocx.CompressionRate = comRate;
				ocx.AutoDeskew = 1;
				var ContVal = document.getElementById("Contrast").value;
				ocx.Contrast = ContVal;
				var bSmooth = document.getElementById("SetSmooth").checked;
				var nStrength = document.getElementById("smoothStrength").selectedIndex;
				var bremoveBG = document.getElementById("removeBG").checked;
				if(nStrength == 0)
				{
					nStrength = 2;
				}
				/*if(bSmooth)
				{
					ocx.SetBackgroundSmooth(bSmooth, 0,0,0,0,nStrength,bremoveBG);
				}
				else
				{
					ocx.SetBackgroundSmooth(bSmooth, 0,0,0,0,nStrength,bremoveBG);
				}*/
        if (1==ocx.Scan(-1,0))
        {

            var img_count=ocx.GetScanImageCount();
           // alert("扫描成功,共计"+img_count+"张");
        }
    }

		function Close()
	  {

		//ocx.SetClearSmartCalibrationData();

		/*var nVal;
		nVal=ocx.GetBlankPageFideSensitivity();
		alert(nVal);
		ocx.SetBlankPageFindSensitivity(1);*/

	
	      if(1==ocx.CloseScanner())
	      {
	         alert("close scanner");
	      }
		//ocx.FreeLibraryEngine();
	  }

	function OCR()
	{
		var nVal=0;
		nVal=ocx.RecognizeFile ("d:\\aaa.jpg","C:\\Temp.txt",0,0,"0,0,0,0",1);
		alert(nVal);
		//nVal=ocx.RecognizeForMulitiFile("E:\\Image",0,"E:\\Image\\Test.PDF",13,64);
		//var sVal;
		//sVal=ocx.RecognizeFileEx("D:\\aaaa.jpg",0,0,"0,0,0,0",1,1);
		//alert(sVal);
	}

	function BarCode()
	{

		//ocx.UpImageFileEx("172.17.7.204",8080,"/aaa","D:\\Test.jpg");
		var sVal="";
		sVal=ocx.GetBarcodeEx1("D:\\Test1.jpg",0,0,0,0);
		alert(sVal);
		//ocx.ImageToWord("D:\\imageTest","D:\\imageTest\\Test.doc","jpg");	
	}
	function Rotation()
	{
		var AngleValue = document.getElementById("Angle").value;
		if(0 == AngleValue)
		{
			return;
		}
		var nRet = ocx.RotationImage(AngleValue);
	}
</script>
<script  LANGUAGE=Javascript  FOR= "ocx" EVENT= "PostScanEveryPage(bSuccess)" defer>
	var ImgPathValue; 
	var imgpath="";
	ImgPathValue = ocx.GetCurrentScanImagePath();
	imgpath+=ImgPathValue+"|";
    document.getElementById("picshow").innerHTML+="<img src="+ ImgPathValue+" width=200 height=300 />&nbsp;&nbsp;";
	document.getElementById("imgpath").value+=ImgPathValue+"|";
</script>

<input   id=btnOpen  type="button"  value=OpenScanner onclick="Open()">
<input   id=btnScan  type="button"  value=Scan onclick="Scan()">
<input   id=btnClose type="button"  value=CloseScanner onclick="Close()">
<input   id=btnOCR type="button"  value=OCR onclick="OCR()">
<input   id=btnBarCode type="button"  value=BarCode onclick="BarCode()">
<br>
<br>
图像路径 <input id = "FilePath" type = "text" value = "E:\image" />
图像前缀 <input id = "FilePrefix" type = "text" value = "abc" />
分辨率<input id = "Resolution" type = "text" value = "200" />
<br><br>
图标保存类型
<select id="PicType">    
         <option value="0">BW</option>    
         <option value="1">GRAY</option>    
         <option value="2">RGB</option>    
</select> 

扫描仪类型
<select id="ScannerType">    
         <option value="0">平板</option>    
         <option value="1">ADF单扫</option>    
         <option value="2">ADF双扫</option>    
</select> 

图标保存格式
<select id="PicTypeEx">    
         <option value="1">bmp</option>    
         <option value="2">jpg</option>    
         <option value="3">tif</option>   
         <option value="4">multitif</option>    
         <option value="5">pdf</option>    
         <option value="6">multipdf</option>   	
		 <option value="7">可检索的单页PDF</option>   			 
</select> 


Tiff压缩
<select id="TiffCom">    
         <option value="1">NULL</option>    
         <option value="2">JPG压缩</option>    
         <option value="3">G4压缩</option>     			 
</select> 
<br><br>
压缩质量 <input id = "CompressRate" type = "text" value = "20" />
对比度 <input id="Contrast" type = "text" value = "0"/>
<br><br>

使用背景平滑功能 <input type="checkbox" id = "SetSmooth" value="1" > 
<br><br>
删除背景 <input type="checkbox" id = "removeBG" value="1" >
<br><br>
平滑强度
<select id="smoothStrength">    
         <option value="1">默认</option>    
         <option value="2">低</option>    
         <option value="3">中</option>    
         <option value="4">高</option>     			 
</select> 

<input   id=btnOpen  type="button"  value="旋转" onclick="Rotation()">

旋转角度<input id = "Angle" type = "text" value = "0" />
<br>
<input  id="imgpath" type="text" value="" style="width:600px;">
<div id="picshow"></div>

</body>
</html>